<!DOCTYPE html>
<html class="writer-html5" lang="en" data-content_root="../">
<head>
  <meta charset="utf-8" /><meta name="viewport" content="width=device-width, initial-scale=1" />

  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  <title>Programming &mdash; The Logtalk Handbook v3.93.0-b01 documentation</title>
      <link rel="stylesheet" type="text/css" href="../_static/pygments.css?v=d75fae25" />
      <link rel="stylesheet" type="text/css" href="../_static/css/theme.css?v=19f00094" />
      <link rel="stylesheet" type="text/css" href="../_static/css/custom.css?v=396eccfe" />

  
  <!--[if lt IE 9]>
    <script src="../_static/js/html5shiv.min.js"></script>
  <![endif]-->
  
        <script src="../_static/jquery.js?v=5d32c60e"></script>
        <script src="../_static/_sphinx_javascript_frameworks_compat.js?v=2cd50e6c"></script>
        <script src="../_static/documentation_options.js?v=c8100655"></script>
        <script src="../_static/doctools.js?v=9a2dae69"></script>
        <script src="../_static/sphinx_highlight.js?v=dc90522c"></script>
    <script src="../_static/js/theme.js"></script>
    <!-- begin favicon -->
    <link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png" />
    <link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png" />
    <link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png" />
    <link rel="manifest" href="/site.webmanifest" />
    <link rel="mask-icon" href="/safari-pinned-tab.svg" color="#5bbad5" />
    <meta name="msapplication-TileColor" content="#355b95" />
    <meta name="theme-color" content="#ffffff" />
    <!-- end favicon -->
    
    <link rel="index" title="Index" href="../genindex.html" />
    <link rel="search" title="Search" href="../search.html" />
    <link rel="next" title="Troubleshooting" href="troubleshooting.html" />
    <link rel="prev" title="Portability" href="portability.html" />
   
</head>

<body class="wy-body-for-nav"> 
  <div class="wy-grid-for-nav">
    <nav data-toggle="wy-nav-shift" class="wy-nav-side">
      <div class="wy-side-scroll">
        <div class="wy-side-nav-search" >

          
          
          <a href="../index.html" class="icon icon-home">
            The Logtalk Handbook
              <img src="../_static/logtalk.gif" class="logo" alt="Logo"/>
          </a>
              <div class="version">
                3.93.0
              </div>
<div role="search">
  <form id="rtd-search-form" class="wy-form" action="../search.html" method="get">
    <input type="text" name="q" placeholder="Search docs" aria-label="Search docs" />
    <input type="hidden" name="check_keywords" value="yes" />
    <input type="hidden" name="area" value="default" />
  </form>
</div>
        </div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu">
    
              <p class="caption" role="heading"><span class="caption-text">Contents</span></p>
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="../userman/index.html">User Manual</a></li>
<li class="toctree-l1"><a class="reference internal" href="../refman/index.html">Reference Manual</a></li>
<li class="toctree-l1"><a class="reference internal" href="../tutorial/index.html">Tutorial</a></li>
<li class="toctree-l1 current"><a class="reference internal" href="index.html">FAQ</a><ul class="current">
<li class="toctree-l2"><a class="reference internal" href="general.html">General</a></li>
<li class="toctree-l2"><a class="reference internal" href="compatibility.html">Compatibility</a></li>
<li class="toctree-l2"><a class="reference internal" href="installation.html">Installation</a></li>
<li class="toctree-l2"><a class="reference internal" href="portability.html">Portability</a></li>
<li class="toctree-l2 current"><a class="current reference internal" href="#">Programming</a><ul>
<li class="toctree-l3"><a class="reference internal" href="#should-i-use-prototypes-or-classes-in-my-application">Should I use prototypes or classes in my application?</a></li>
<li class="toctree-l3"><a class="reference internal" href="#can-i-use-both-classes-and-prototypes-in-the-same-application">Can I use both classes and prototypes in the same application?</a></li>
<li class="toctree-l3"><a class="reference internal" href="#can-i-mix-classes-and-prototypes-in-the-same-hierarchy">Can I mix classes and prototypes in the same hierarchy?</a></li>
<li class="toctree-l3"><a class="reference internal" href="#can-i-use-a-protocol-or-a-category-with-both-prototypes-and-classes">Can I use a protocol or a category with both prototypes and classes?</a></li>
<li class="toctree-l3"><a class="reference internal" href="#what-support-is-provided-in-logtalk-for-defining-and-using-components">What support is provided in Logtalk for defining and using components?</a></li>
<li class="toctree-l3"><a class="reference internal" href="#what-support-is-provided-in-logtalk-for-reflective-programming">What support is provided in Logtalk for reflective programming?</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="troubleshooting.html">Troubleshooting</a></li>
<li class="toctree-l2"><a class="reference internal" href="usability.html">Usability</a></li>
<li class="toctree-l2"><a class="reference internal" href="deployment.html">Deployment</a></li>
<li class="toctree-l2"><a class="reference internal" href="performance.html">Performance</a></li>
<li class="toctree-l2"><a class="reference internal" href="licensing.html">Licensing</a></li>
<li class="toctree-l2"><a class="reference internal" href="support.html">Support</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../devtools/index.html">Developer Tools</a></li>
<li class="toctree-l1"><a class="reference internal" href="../libraries/index.html">Libraries</a></li>
<li class="toctree-l1"><a class="reference internal" href="../ports/index.html">Ports</a></li>
<li class="toctree-l1"><a class="reference internal" href="../contributions/index.html">Contributions</a></li>
<li class="toctree-l1"><a class="reference internal" href="../glossary.html">Glossary</a></li>
<li class="toctree-l1"><a class="reference internal" href="../bibliography.html">Bibliography</a></li>
<li class="toctree-l1"><a class="reference internal" href="../genindex.html">Index</a></li>
</ul>

    <p class="caption"><span class="caption-text">External Contents</span></p>
    <ul>
    <li class="toctree-l1"><a class="reference internal" href="../../apis/index.html">APIs</a></li>
    <li class="toctree-l1"><a class="reference internal" href="https://logtalk.org">Logtalk website</a></li>
    <li class="toctree-l1"><a class="reference internal" href="https://github.com/LogtalkDotOrg/logtalk3">GitHub repo</a></li>
    </ul>
  
        </div>
      </div>
    </nav>

    <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"><nav class="wy-nav-top" aria-label="Mobile navigation menu" >
          <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
          <a href="../index.html">The Logtalk Handbook</a>
      </nav>

      <div class="wy-nav-content">
        <div class="rst-content">
          <div role="navigation" aria-label="Page navigation">
  <ul class="wy-breadcrumbs">
      <li><a href="../index.html" class="icon icon-home" aria-label="Home"></a></li>
          <li class="breadcrumb-item"><a href="index.html">FAQ</a></li>
      <li class="breadcrumb-item active">Programming</li>
      <li class="wy-breadcrumbs-aside">
              <a href="https://github.com/LogtalkDotOrg/logtalk3/blob/master/docs/handbook/sources/faq/programming.rst" class="fa fa-github"> Edit on GitHub</a>
      </li>
  </ul>
  <hr/>
</div>
          <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
           <div itemprop="articleBody">
             
  <section id="programming">
<span id="faq-programming"></span><h1>Programming<a class="headerlink" href="#programming" title="Link to this heading"></a></h1>
<ul class="simple">
<li><p><a class="reference internal" href="#faq-programming-either-prototypes-classes"><span class="std std-ref">Should I use prototypes or classes in my application?</span></a></p></li>
<li><p><a class="reference internal" href="#faq-programming-both-prototypes-classes"><span class="std std-ref">Can I use both classes and prototypes in the same application?</span></a></p></li>
<li><p><a class="reference internal" href="#faq-programming-hierarchy"><span class="std std-ref">Can I mix classes and prototypes in the same hierarchy?</span></a></p></li>
<li><p><a class="reference internal" href="#faq-programming-protocols-categories"><span class="std std-ref">Can I use a protocol or a category with both prototypes and classes?</span></a></p></li>
<li><p><a class="reference internal" href="#faq-programming-components"><span class="std std-ref">What support is provided in Logtalk for defining and using components?</span></a></p></li>
<li><p><a class="reference internal" href="#faq-programming-reflection"><span class="std std-ref">What support is provided in Logtalk for reflective programming?</span></a></p></li>
</ul>
<section id="should-i-use-prototypes-or-classes-in-my-application">
<span id="faq-programming-either-prototypes-classes"></span><h2>Should I use prototypes or classes in my application?<a class="headerlink" href="#should-i-use-prototypes-or-classes-in-my-application" title="Link to this heading"></a></h2>
<p>Prototypes and classes provide different patterns of code reuse. A
prototype encapsulates code that can be used by itself and by its
descendent prototypes. A class encapsulates code to be used by its
descendent instances. Prototypes provide the best replacement to the
use of modules as encapsulation units, avoiding the need to
instantiate a class in order to access its code.</p>
</section>
<section id="can-i-use-both-classes-and-prototypes-in-the-same-application">
<span id="faq-programming-both-prototypes-classes"></span><h2>Can I use both classes and prototypes in the same application?<a class="headerlink" href="#can-i-use-both-classes-and-prototypes-in-the-same-application" title="Link to this heading"></a></h2>
<p>Yes. In addition, you may freely exchange messages between
prototypes, classes, and instances.</p>
</section>
<section id="can-i-mix-classes-and-prototypes-in-the-same-hierarchy">
<span id="faq-programming-hierarchy"></span><h2>Can I mix classes and prototypes in the same hierarchy?<a class="headerlink" href="#can-i-mix-classes-and-prototypes-in-the-same-hierarchy" title="Link to this heading"></a></h2>
<p>No. However, you may define as many prototype hierarchies and class
hierarchies and classes as needed by your application.</p>
</section>
<section id="can-i-use-a-protocol-or-a-category-with-both-prototypes-and-classes">
<span id="faq-programming-protocols-categories"></span><h2>Can I use a protocol or a category with both prototypes and classes?<a class="headerlink" href="#can-i-use-a-protocol-or-a-category-with-both-prototypes-and-classes" title="Link to this heading"></a></h2>
<p>Yes. A protocol may be implemented by both prototypes and classes in
the same application. Likewise, a category may be imported by both
prototypes and classes in the same application.</p>
</section>
<section id="what-support-is-provided-in-logtalk-for-defining-and-using-components">
<span id="faq-programming-components"></span><h2>What support is provided in Logtalk for defining and using components?<a class="headerlink" href="#what-support-is-provided-in-logtalk-for-defining-and-using-components" title="Link to this heading"></a></h2>
<p>Logtalk supports component-based programming (since its inception on
January 1998), by using <em>categories</em> (which are first-class entities
like objects and protocols). Logtalk categories can be used with both
classes and prototypes and are inspired by the Smalltalk-80
(documentation-only) concept of method categories and by Objective-C
categories, hence the name. For more information, please consult the
<a class="reference internal" href="../userman/categories.html#categories-categories"><span class="std std-ref">Categories</span></a> section and the examples provided with
the distribution.</p>
</section>
<section id="what-support-is-provided-in-logtalk-for-reflective-programming">
<span id="faq-programming-reflection"></span><h2>What support is provided in Logtalk for reflective programming?<a class="headerlink" href="#what-support-is-provided-in-logtalk-for-reflective-programming" title="Link to this heading"></a></h2>
<p>Logtalk supports meta-classes, behavioral reflection through the use
of event-driven programming, and structural reflection through the
use of a set of built-in predicates and built-in methods which allow
us to query the system about existing entities, entity relations, and
entity predicates.</p>
</section>
</section>


           </div>
          </div>
          <footer><div class="rst-footer-buttons" role="navigation" aria-label="Footer">
        <a href="portability.html" class="btn btn-neutral float-left" title="Portability" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a>
        <a href="troubleshooting.html" class="btn btn-neutral float-right" title="Troubleshooting" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right" aria-hidden="true"></span></a>
    </div>

  <hr/>

  <div role="contentinfo">
    <p>&#169; Copyright 1998-2025, Paulo Moura.</p>
  </div>

  Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a
    <a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a>
    provided by <a href="https://readthedocs.org">Read the Docs</a>.
   

</footer>
        </div>
      </div>
    </section>
  </div>
  <script>
      jQuery(function () {
          SphinxRtdTheme.Navigation.enable(true);
      });
  </script> 

</body>
</html>